<template>
  <div>
    <f-table ref='table' size='small' rowKey='paymentId' :showSetting='true' setting-key='pay_payment_tab2' :tableColumns='columns' :scroll='{x:true}' :multiple='false' :operator='operator' :params='queryParam' :api='api.payment' handler='refundHkTab4PageListHandler'>
       <span slot='paymentState' slot-scope='text, record, index'>
            <a-tag color='#87d068' v-if='text==0'>未提交</a-tag>
            <a-tag color='#108ee9' v-if='text==1'>审批中</a-tag>
            <a-tag color='#EE4B2B' v-if='text==2'>已退款</a-tag>
       </span>
      <span slot='action' slot-scope='text, record'>
          <template>
            <a @click='startProcess(record.paymentId,"refundAmountStartProcessHandler")' v-if='record.paymentState==0'>提交</a>
             <a @click='completeTask(record)' v-if="record.taskDefinitionKey&&record.taskDefinitionKey=='__initiator__'">提交</a>
              <a-divider type='vertical' v-if="record.paymentState==0||record.taskDefinitionKey=='__initiator__'"/>
             <a @click="$refs.refundDrawer.showDrawer(record,'form1')" v-if="record.paymentState==0||record.taskDefinitionKey=='__initiator__'">编辑</a>
            <a-divider type='vertical' />
            <a-dropdown>
             <a class='ant-dropdown-link'>更多<a-icon type='down' /></a>
             <a-menu slot='overlay'>
                 <a-menu-item v-if='record.paymentState==0'>
                  <a href='javascript:;' @click="$refs.table.del(record,{handlerName:'refundHkPaymentDeleteHandler',processInstanceId:record.processInstanceId})">删除</a>
                </a-menu-item>
                <a-menu-item v-if='record.paymentState!=0'>
                    <a href='javascript:;' @click='processImg(record)'>审批进度</a>
                </a-menu-item>
                <a-menu-item>
                <a href='javascript:;' @click='printPayment(record.paymentId)'>打印单据</a>
              </a-menu-item>
             </a-menu>
            </a-dropdown>
          </template>
        </span>
    </f-table>
    <process-image ref='processImg' v-if='processImageVisible' :visible.sync='processImageVisible' :processInstanceId='processInstanceId'></process-image>
    <print-modal ref='printModal'></print-modal>
    <refund-drawer ref='refundDrawer'></refund-drawer>
  </div>
</template>
<script>

import api from "@/views/module/haiying/js/api"
import ProcessImage from "@/views/module/flowable/process/process_image"
import { processMixins } from "@/core/mixins/processMixins"
import PrintModal from "@/views/module/haiying/print/print_modal"
import RefundDrawer from "@/views/module/haiying/custombalance/components/refund_drawer"

export default {
  name: "Tab4",
  components: {
    RefundDrawer,
    PrintModal,
    ProcessImage
  },
  mixins: [processMixins],
  data() {
    let me = this
    //操作按钮
    let operator = []

    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: { paymentState: 1 },
      processInstanceId: "",
      processImageVisible: false,
      // 表头
      columns: [
        {
          title: "序号",
          width: "60",
          align: "center",
          customRender: (text, record, index) => index + 1
        },
        {
          title: "退款单号",
          align: "center",
          width: "100px",
          dataIndex: "paymentNo"
        },
        {
          title: "申请日期",
          align: "center",
          width: "80px",
          dataIndex: "amountDate"
        },
        {
          title: "申请部门",
          align: "left",
          width: "100px",
          dataIndex: "applyDeptName"
        },
        {
          title: "收款单位",
          align: "left",
          width: "150px",
          ellipsis: true,
          dataIndex: "customName"
        },
        {
          title: "收款银行",
          align: "left",
          dataIndex: "bankName"
        },
        {
          title: "收款账户",
          align: "left",
          dataIndex: "bankNo"
        },
        {
          title: "退款金额",
          align: "center",
          dataIndex: "amount"
        },
        {
          title: "退款日期",
          align: "center",
          dataIndex: "payDate"
        },
        {
          title: "制单人",
          align: "center",
          dataIndex: "nickName"
        }, {
          title: "状态",
          align: "center",
          width: "80px",
          fixed: "right",
          dataIndex: "paymentState",
          scopedSlots: { customRender: "paymentState" }
        },
        {
          title: "操作",
          align: "center",
          fixed: "right",
          dataIndex: "action",
          width: "140px",
          scopedSlots: { customRender: "action" }
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  methods: {
    onLoad() {
      this.$refs.table.refresh()
    },
    processImg(task) {
      this.processInstanceId = task.processInstanceId
      this.processImageVisible = true
    },
    /**
     * 查询事件
     * @param searchParams
     */
    searchTable(searchParams) {
      this.queryParam = Object.assign(this.queryParam, searchParams)
      this.$refs.table.refresh(true, searchParams)
    },
    //打印单
    printPayment(paymentId) {
      this.$refs["printModal"].open(paymentId, 2, "RefundHk")
    }
  }
}
</script>
